package com.lanou.myapp.main;


import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TabHost;

import com.lanou.myapp.R;
import com.lanou.myapp.book.BookFragment;
import com.lanou.myapp.comic.ComicFragment;
import com.lanou.myapp.funny.FunnyFragment;
import com.lanou.myapp.mode.DayNightMode;
import com.lanou.myapp.news.NewsFragment;
import com.lanou.myapp.person.PersonFragment;
import com.lanou.myapp.circlepicture.ArcMenu;


public class MainActivity extends AppCompatActivity{
    private TabHost tabHost;
    private ArcMenu arcMenu;
    private FragmentManager fm;
    private ImageView iv_share;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        DayNightMode.onActivityCreateSetTheme(this);
        setContentView(R.layout.activity_main);
        arcMenu = (ArcMenu) findViewById(R.id.arcMenu);


        tabHost = (TabHost) findViewById(android.R.id.tabhost);
        tabHost.setup();

        View viewNews = LayoutInflater.from(this).inflate(R.layout.tabhost_news, null);
        tabHost.addTab(tabHost.newTabSpec("news").setIndicator(viewNews).setContent(R.id.news));

        View viewBook = LayoutInflater.from(this).inflate(R.layout.tabhost_book, null);
        tabHost.addTab(tabHost.newTabSpec("book").setIndicator(viewBook).setContent(R.id.book));

        View viewComic = LayoutInflater.from(this).inflate(R.layout.tabhost_comic, null);
        tabHost.addTab(tabHost.newTabSpec("comic").setIndicator(viewComic).setContent(R.id.comic));

        View viewFunny = LayoutInflater.from(this).inflate(R.layout.tabhost_funny, null);
        tabHost.addTab(tabHost.newTabSpec("funny").setIndicator(viewFunny).setContent(R.id.funny));

        View viewPerson = LayoutInflater.from(this).inflate(R.layout.tabhost_person, null);
        tabHost.addTab(tabHost.newTabSpec("person").setIndicator(viewPerson).setContent(R.id.person));

        fm = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = fm.beginTransaction();
        fragmentTransaction.replace(R.id.news, new NewsFragment());
        fragmentTransaction.replace(R.id.book, new BookFragment());
        fragmentTransaction.replace(R.id.comic, new ComicFragment());
        fragmentTransaction.replace(R.id.funny, new FunnyFragment());
        fragmentTransaction.replace(R.id.person, new PersonFragment());
        fragmentTransaction.commit();
//        initEvent();
    }


    //卫星菜单
//    private void initEvent() {
//        arcMenu.setOnMenuItemClickListener(new ArcMenu.OnMenuItemClickListener() {
//            @Override
//            public void onClick(View view, int pos) {
//                Toast.makeText(MainActivity.this, pos + ":" + view.getTag(), Toast.LENGTH_SHORT).show();
//            }
//        });
//    }
//
}
